﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace YBOT_Field_Control
{
    public partial class Score : Form
    {
        
        public bool finalScore = false;
        Game sGame;

        public Score()
        {
            InitializeComponent();
        }

        public Score(Game _game)
        {
            InitializeComponent();
            this.sGame = _game;
        }

        private void Score_Shown(object sender, EventArgs e)
        {
            this.tbRedScore.Text = this.sGame.red.score.ToString();
            this.tbGreenScore.Text = this.sGame.green.score.ToString();
            this.tbComputerScore.Text = this.sGame.computer.score.ToString();
        }

        private void btnFinalScore_Click(object sender, EventArgs e)
        {

            this.sGame.green.finalScore = Convert.ToInt16(this.tbGreenScore.Text);
            this.sGame.red.finalScore = Convert.ToInt16(this.tbRedScore.Text);
            this.sGame.computer.finalScore = Convert.ToInt16(this.tbComputerScore.Text);
            this.sGame.green.score = this.sGame.green.finalScore;
            this.sGame.red.score = this.sGame.red.finalScore;
            this.sGame.computer.score = this.sGame.computer.finalScore;
            this.finalScore = true;
        }

        private void cbRedGlobes_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.sGame.red.scoredGlobes = Convert.ToInt16(this.cbRedGlobes.Text);
            this.sGame.red.finalScore = ((this.sGame.red.scoredGlobes * this.sGame.globePoints) + this.sGame.red.score);
            this.tbRedScore.Text = this.sGame.red.finalScore.ToString();

            this.sGame.computer.scoredGlobes = 14 - (this.sGame.red.scoredGlobes + this.sGame.green.scoredGlobes);
            this.cbComputerGlobes.Text = this.sGame.computer.scoredGlobes.ToString();
            this.sGame.computer.finalScore = ((this.sGame.computer.scoredGlobes * this.sGame.globePoints) + this.sGame.computer.score);
            this.tbComputerScore.Text = this.sGame.computer.finalScore.ToString();
        }

        private void cbGreenGlobes_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.sGame.green.scoredGlobes = Convert.ToInt16(this.cbGreenGlobes.Text);
            this.sGame.green.finalScore = ((this.sGame.green.scoredGlobes * this.sGame.globePoints) + this.sGame.green.score);
            this.tbGreenScore.Text = this.sGame.green.finalScore.ToString();

            this.sGame.computer.scoredGlobes = 14 - (this.sGame.red.scoredGlobes + this.sGame.green.scoredGlobes);
            this.cbComputerGlobes.Text = this.sGame.computer.scoredGlobes.ToString();
            this.sGame.computer.finalScore = ((this.sGame.computer.scoredGlobes * this.sGame.globePoints) + this.sGame.computer.score);
            this.tbComputerScore.Text = this.sGame.computer.finalScore.ToString();
        }

    }
}
